package com.ruoyi.demo.service.base.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.demo.domain.DemoCustomer;
import com.ruoyi.demo.mapper.DemoCustomerMapper;
import com.ruoyi.demo.service.base.DemoCustomerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户信息Service业务层处理
 *
 * @author zhangshu
 * @date 2021-01-26
 */
@Service
public class DemoCustomerServiceImpl extends ServiceImpl<DemoCustomerMapper, DemoCustomer> implements DemoCustomerService {

    @Override
    public List<DemoCustomer> queryList(DemoCustomer demoCustomer) {
        LambdaQueryWrapper<DemoCustomer> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(demoCustomer.getCustomerName())){
            lqw.like(DemoCustomer::getCustomerName ,demoCustomer.getCustomerName());
        }
        if (StringUtils.isNotBlank(demoCustomer.getPhonenumber())){
            lqw.eq(DemoCustomer::getPhonenumber ,demoCustomer.getPhonenumber());
        }
        if (StringUtils.isNotBlank(demoCustomer.getSex())){
            lqw.eq(DemoCustomer::getSex ,demoCustomer.getSex());
        }
        if (demoCustomer.getBirthday() != null){
            lqw.eq(DemoCustomer::getBirthday ,demoCustomer.getBirthday());
        }
        if (StringUtils.isNotBlank(demoCustomer.getRemark())){
            lqw.eq(DemoCustomer::getRemark ,demoCustomer.getRemark());
        }
        return this.list(lqw);
    }
}
